package com.example.group_20.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.group_20.entity.Students;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author: 栋
 * @data: 2023/8/11
 * @descriptions:
 */
@Mapper
public interface StudentsMapper extends BaseMapper<Students> {
    @Select("select * from students where s_id=#{s_id}")
    public Students findByid(String s_id);

    @Select("select * from students where group_id=#{group_id}")
    public List<Students> findByGroup(int group_id);

    @Update("update students set s_email=#{s_email},s_tel=#{s_tel},s_password=#{s_password},group_id=#{group_id},leader=#{leader} where s_id=#{s_id}")
    public int updateInfor(Students students);

    @Select("select * from students")
    public List<Students> findAll();

    @Update("update students set group_id=group_id-1 where group_id>#{group_id}")
    public int updateStudentGroupId(int group_id);
}
